package temp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class conDB {
	Connection c = null;
	Statement s1 = null;
	public void closeDB(){
		try{
			if (s1 != null) {s1.close();}
			if (c != null) {c.close();}
		}catch(SQLException e)
		{
			e.printStackTrace();
		}
	}
	public Statement connectDB(String url){
		try{
			Class.forName("org.postgresql.Driver");
    		c = DriverManager.getConnection(url,"postgres","postgres");
    		s1 = c.createStatement();
    		return s1;
		}catch (Exception e) {
			System.out.println("???");
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return s1;
	}
	public Statement connectDB_r(String url){
		try{
			Class.forName("org.postgresql.Driver");
    		c = DriverManager.getConnection(url,"postgres","postgres");
    		s1 = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet. CONCUR_READ_ONLY);
    		return s1;
		}catch (Exception e) {
			System.out.println("???");
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return s1;
	}
}
